package com.kg.tombs.service;

import com.kg.tombs.db.MongoVerticle;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;

import java.util.List;

public class DataService {


    private final Vertx vertx;

    private final MongoVerticle mongoVerticle;

    public DataService(Vertx vertx, MongoVerticle mongoVerticle) {
        this.vertx = vertx;
        this.mongoVerticle = mongoVerticle;
    }

    public Future<List<JsonObject>> getAll(String collection) {
        return Future.future(promise -> mongoVerticle.find(collection, new JsonObject()));
    }

    public Future<Void> batchInsert(String collection, List<JsonObject> documents) {
        return Future.future(promise ->  mongoVerticle.insertMany(collection, documents));
    }

}
